package org.jeeasy.common.core.domain;

import cn.hutool.core.bean.BeanUtil;

import java.io.Serializable;
import java.util.Collection;

/**
 * @author AlpsDDJ
 * @version v1.0
 * @description JeeasyAuthUser 自定义认证用户接口
 * @date 2020-11-14
 */
public interface IAuthUser extends Serializable {

    String SESSION_KEY = "auth:session:user:";
    String SUPER_USERNAME = "admin";

    static <T extends IAuthUser> T create(Object user, Class<T> clazz) {
        return BeanUtil.copyProperties(user, clazz);
    }

    Collection<String> getRoleSet();

    Collection<String> getPermissionSet();

    String id();

    String password();

    String username();

    default String deptCode() {
        return null;
    }

    default boolean izAccountNonExpired() {
        return true;
    }

    default boolean izAccountNonLocked() {
        return true;
    }

    default boolean izCredentialsNonExpired() {
        return true;
    }

    default boolean izEnabled() {
        return true;
    }

}
